package com.ruoyi.gis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gis.domain.DatasetRasterTaskData;
import com.ruoyi.gis.service.IDatasetRasterTaskDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 遥感监测任务Controller
 * 
 * @author rww
 * @date 2024-09-21
 */
@RestController
@RequestMapping("/earthai/rasterTaskData")
public class DatasetRasterTaskDataController extends BaseController
{
    @Autowired
    private IDatasetRasterTaskDataService datasetRasterTaskDataService;

    /**
     * 查询遥感监测任务列表
     */
    @PreAuthorize("@ss.hasPermi('earthai:rasterTaskData:list')")
    @GetMapping("/list")
    public TableDataInfo list(DatasetRasterTaskData datasetRasterTaskData)
    {
        startPage();
        List<DatasetRasterTaskData> list = datasetRasterTaskDataService.selectDatasetRasterTaskDataList(datasetRasterTaskData);
        return getDataTable(list);
    }

    /**
     * 导出遥感监测任务列表
     */
    @PreAuthorize("@ss.hasPermi('earthai:rasterTaskData:export')")
    @Log(title = "遥感监测任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DatasetRasterTaskData datasetRasterTaskData)
    {
        List<DatasetRasterTaskData> list = datasetRasterTaskDataService.selectDatasetRasterTaskDataList(datasetRasterTaskData);
        ExcelUtil<DatasetRasterTaskData> util = new ExcelUtil<DatasetRasterTaskData>(DatasetRasterTaskData.class);
        util.exportExcel(response, list, "遥感监测任务数据");
    }

    /**
     * 获取遥感监测任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('earthai:rasterTaskData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(datasetRasterTaskDataService.selectDatasetRasterTaskDataById(id));
    }

    /**
     * 新增遥感监测任务
     */
    @PreAuthorize("@ss.hasPermi('earthai:rasterTaskData:add')")
    @Log(title = "遥感监测任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DatasetRasterTaskData datasetRasterTaskData)
    {
        return toAjax(datasetRasterTaskDataService.insertDatasetRasterTaskData(datasetRasterTaskData));
    }

    /**
     * 修改遥感监测任务
     */
    @PreAuthorize("@ss.hasPermi('earthai:rasterTaskData:edit')")
    @Log(title = "遥感监测任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DatasetRasterTaskData datasetRasterTaskData)
    {
        return toAjax(datasetRasterTaskDataService.updateDatasetRasterTaskData(datasetRasterTaskData));
    }

    /**
     * 删除遥感监测任务
     */
    @PreAuthorize("@ss.hasPermi('earthai:rasterTaskData:remove')")
    @Log(title = "遥感监测任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(datasetRasterTaskDataService.deleteDatasetRasterTaskDataByIds(ids));
    }
}
